package com.vogue.sms.modules.monitor.controller;

import java.util.Arrays;
import java.util.Map;

import com.vogue.sms.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.vogue.sms.modules.monitor.entity.UserEquipmentEntity;
import com.vogue.sms.modules.monitor.service.UserEquipmentService;
import com.vogue.sms.common.utils.PageUtils;
import com.vogue.sms.common.utils.R;



/**
 * 用户设备
 *
 * @author George
 * @email qiaozhi_china@163.com
 * @date 2018-12-02 23:04:30
 */
@RestController
@RequestMapping("monitor/userequipment")
public class UserEquipmentController {
    @Autowired
    private UserEquipmentService userEquipmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("monitor:userequipment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userEquipmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("monitor:userequipment:info")
    public R info(@PathVariable("id") Integer id){
        UserEquipmentEntity userEquipment = userEquipmentService.selectById(id);

        return R.ok().put("userEquipment", userEquipment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("monitor:userequipment:save")
    public R save(@RequestBody UserEquipmentEntity userEquipment){
        userEquipmentService.insert(userEquipment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("monitor:userequipment:update")
    public R update(@RequestBody UserEquipmentEntity userEquipment){
        ValidatorUtils.validateEntity(userEquipment);
        userEquipmentService.updateAllColumnById(userEquipment);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("monitor:userequipment:delete")
    public R delete(@RequestBody Integer[] ids){
        userEquipmentService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
